﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Common.Net.Gui
{
    public static class ControlHoster
    {
        public static Form Show(Control control, string caption)
        {
            return Show(control, () => new Form { Text = caption });
        }

        public static TForm Show<TForm>(Control control, Func<TForm> createForm)
            where TForm : Form
        {
            var form = createForm();

            form.ClientSize = control.Size;
            control.Dock = DockStyle.Fill;
            form.Controls.Add(control);
            form.Show();

            return form;
        }
    }
}
